//function to submit moves, updates, & deletes from the switch board on left rail of Grid Planner
function submitSwitchboard(){
	var cMsg = "";
	var dMsg = "";

	if(movesArray.length > 0 || copyArray.length > 0){
		 cMsg = "* If there's a spot located where you are copying or moving to, IT WILL BE ERASED!";
	}
	if(deleteArray.length > 0){
		dMsg = "* The selected spot(s) will be deleted immediately!";
	}

	if(movesArray.length < 1 && copyArray.length < 1 && deleteArray.length < 1){//just updates to process so send it on
				//Variables and info for moves
				var addHiddenFields = "<input name=\"movesTotal\" type=\"hidden\" value=\"" + movesArray.length + "\">";
				for (var q=0; q < movesArray.length; q++) {
					addHiddenFields = addHiddenFields + "<input name=\"move" + q + "\" type=\"hidden\" value=\"" + movesArray[q].ID + ":" + movesArray[q].time + ":" + movesArray[q].mon + ":" + movesArray[q].tue + ":" + movesArray[q].wed + ":" + movesArray[q].thu + ":" + movesArray[q].fri + ":" + movesArray[q].sat + ":" + movesArray[q].sun +"\">" ;
				}
				
				//Variables for Copies
				addHiddenFields = addHiddenFields + "<input name=\"copyTotal\" type=\"hidden\" value=\"" + copyArray.length + "\">";
				for (var q=0; q < copyArray.length; q++) {
					addHiddenFields = addHiddenFields + "<input name=\"copy" + q + "\" type=\"hidden\" value=\"" + copyArray[q].ID + ":" + copyArray[q].time + ":" + copyArray[q].mon + ":" + copyArray[q].tue + ":" + copyArray[q].wed + ":" + copyArray[q].thu + ":" + copyArray[q].fri + ":" + copyArray[q].sat + ":" + copyArray[q].sun +"\">" ;
				}
				
				//Variables for Updates
				addHiddenFields = addHiddenFields + "<input name=\"updatesTotal\" type=\"hidden\" value=\"" + updateArray.length + "\">";
				for (var q=0; q < updateArray.length; q++) {
					addHiddenFields = addHiddenFields + "<input name=\"update" + q + "\" type=\"hidden\" value=\"" + updateArray[q].ID + "\">" ;
				}
				
				//Variables for Deletes
				addHiddenFields = addHiddenFields + "<input name=\"deletesTotal\" type=\"hidden\" value=\"" + deleteArray.length + "\">";
				for (var q=0; q < deleteArray.length; q++) {
					addHiddenFields = addHiddenFields + "<input name=\"delete" + q + "\" type=\"hidden\" value=\"" + deleteArray[q].ID + "\">" + "<input name=\"deleteDays" + q + "\" type=\"hidden\" value=\"" + deleteArray[q].MydisplayDays + "\">";  
					//addHiddenFields = addHiddenFields + "<input name=\"delete" + q + "\" type=\"hidden\" value=\"" + deleteArray[q].ID + ":" + deleteArray[q].time + ":" + deleteArray[q].mon + ":" + deleteArray[q].tue + ":" + deleteArray[q].wed + ":" + deleteArray[q].thu + ":" + deleteArray[q].fri + ":" + deleteArray[q].sat + ":" + deleteArray[q].sun +"\">" ;
				}
				
				
				if(browser == "IE"){
				document.getElementById("hiddenStuff").innerHTML = addHiddenFields;	
				}else{
				document.getElementById("switchBoardUpdates").innerHTML = addHiddenFields;	
				}
				document.updates.submit();
		}else{


 				if(confirm("WARNING! \n" + cMsg + "\n" + dMsg + "\n\n ARE YOU SURE YOU WANT TO PROCEED?")){
			   
					   //Variables and info for moves
						var addHiddenFields = "<input name=\"movesTotal\" type=\"hidden\" value=\"" + movesArray.length + "\">";
						for (var q=0; q < movesArray.length; q++) {
							addHiddenFields = addHiddenFields + "<input name=\"move" + q + "\" type=\"hidden\" value=\"" + movesArray[q].ID + ":" + movesArray[q].time + ":" + movesArray[q].mon + ":" + movesArray[q].tue + ":" + movesArray[q].wed + ":" + movesArray[q].thu + ":" + movesArray[q].fri + ":" + movesArray[q].sat + ":" + movesArray[q].sun +"\">" ;
						}
						
						//Variables for Copies
						addHiddenFields = addHiddenFields + "<input name=\"copyTotal\" type=\"hidden\" value=\"" + copyArray.length + "\">";
						for (var q=0; q < copyArray.length; q++) {
							addHiddenFields = addHiddenFields + "<input name=\"copy" + q + "\" type=\"hidden\" value=\"" + copyArray[q].ID + ":" + copyArray[q].time + ":" + copyArray[q].mon + ":" + copyArray[q].tue + ":" + copyArray[q].wed + ":" + copyArray[q].thu + ":" + copyArray[q].fri + ":" + copyArray[q].sat + ":" + copyArray[q].sun +"\">" ;
						}
						
						//Variables for Updates
						addHiddenFields = addHiddenFields + "<input name=\"updatesTotal\" type=\"hidden\" value=\"" + updateArray.length + "\">";
						for (var q=0; q < updateArray.length; q++) {
							addHiddenFields = addHiddenFields + "<input name=\"update" + q + "\" type=\"hidden\" value=\"" + updateArray[q].ID + "\">" ;
						}
						
						//Variables for Deletes
						addHiddenFields = addHiddenFields + "<input name=\"deletesTotal\" type=\"hidden\" value=\"" + deleteArray.length + "\">";
						for (var q=0; q < deleteArray.length; q++) {
							addHiddenFields = addHiddenFields + "<input name=\"delete" + q + "\" type=\"hidden\" value=\"" + deleteArray[q].ID + "\">" + "<input name=\"deleteDays" + q + "\" type=\"hidden\" value=\"" + deleteArray[q].MydisplayDays + "\">";  
							//addHiddenFields = addHiddenFields + "<input name=\"delete" + q + "\" type=\"hidden\" value=\"" + deleteArray[q].ID + ":" + deleteArray[q].time + ":" + deleteArray[q].mon + ":" + deleteArray[q].tue + ":" + deleteArray[q].wed + ":" + deleteArray[q].thu + ":" + deleteArray[q].fri + ":" + deleteArray[q].sat + ":" + deleteArray[q].sun +"\">" ;
						}
						
						
						if(browser == "IE"){
						document.getElementById("hiddenStuff").innerHTML = addHiddenFields;	
						}else{
						document.getElementById("switchBoardUpdates").innerHTML = addHiddenFields;	
						}
						document.updates.submit();
				
			  }else{
				return false;	
			  }


		}//end else
	
		
}//end function

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// CHECK FOR DUPLICATE SPOTS IN ARRAYS FUNCTION
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function searchArrayDuplicates(originatingArray){
	
	alreadyScheduled = false;


	//LOOK IN MOVES ARRAY to see if current spot is already schedules for action
		for (var q=0; q < movesArray.length; q++) {
			if(movesArray[q].ID == MoveID){
				alreadyScheduled = true;
				alert(MoveSpot + " is already scheduled to be moved!");
				return false;	
				break;
			}
		}
		
	//LOOK IN COPY ARRAY to see if current spot is already schedules for action
	if(originatingArray != 'copy'){
		for (var q=0; q < copyArray.length; q++) {
			if(copyArray[q].ID == MoveID){
				alreadyScheduled = true;
				alert(MoveSpot + " is already scheduled to be copied!");
				return false;	
				break;
			}
		}			
	}//end if
		
	//LOOK IN UPDATES ARRAY to see if current spot is already schedules for action
		for (var q=0; q < updateArray.length; q++) {
			if(updateArray[q].ID == MoveID){
				alreadyScheduled = true;
				alert(MoveSpot + " is already scheduled to be updated!");
				return false;	
				break;
			}
		}		
		
	//LOOK IN DELETES ARRAY to see if current spot is already schedules for action
		for (var q=0; q < deleteArray.length; q++) {
			if(deleteArray[q].ID == MoveID){
				alreadyScheduled = true;
				alert(MoveSpot + " is already scheduled to be updated!");
				return false;	
				break;
			}
		}				
		
	
}//end function




//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// MOVE SPOT FUNCTION
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//removes item from sidebar
function dropMove(spot,ID){
	//alert(movesArray.length);
	//MyID = parseInt(ID);
	movesArray.splice(ID,1);
	//alert(movesArray.length);
	//Populate Move Cell
		var diplayMoves = "";
		for (var q=0; q < movesArray.length; q++) {
					var hour = movesArray[q].time.substring(0,2);
					var rest = movesArray[q].time.substring(2,8);
					Myhour = parseInt(hour);
					if(Myhour > 12){
						var newHour = 12-(24 - Myhour);
						var diplayTime = newHour +  rest + "pm";
					}else{
						var diplayTime = movesArray[q].time + "am";
					}

			diplayMoves = diplayMoves + "&#8226;" + movesArray[q].spot + "<A href=\"javascript:dropMove('" + movesArray[q].spot + "','" + q + "');\"><IMG src=\"images/dropMove.gif\" border=\"0\" align=\"right\"></A><BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + movesArray[q].MydisplayDays + "<BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + diplayTime + "<HR>";
		}
		document.getElementById("Moves").innerHTML = diplayMoves;
}//end dropMove


movesArray = new Array();//array that holds scheduled moves from switchboard

function newMove(ID,spot,time,MydisplayDays,mon,tue,wed,thu,fri,sat,sun){
	this.ID = ID;
	this.spot = spot;
	this.time = time;
	this.MydisplayDays = MydisplayDays;
	this.mon = mon;
	this.tue = tue;
	this.wed = wed;
	this.thu = thu;
	this.fri = fri;
	this.sat = sat;
	this.sun = sun;
}//end newMove




function addMove(){
	
	searchArrayDuplicates('move');
	
				var diplayDays = "";
				var diplayMoves = "";
				var dropDown = eval("document.MyPopUp.time.value");
	
	//determine if time and day have been changed so as not to move a spot back to itself
	//figure out which day is checked...
	somethingChecked = false;
	for (var q=0; q < document.MyPopUp.elements.length; q++) {

				 // get each element of form form
				 var e = document.MyPopUp.elements[q];
				 originalMoveDay = e.name;
				 if(e.type.indexOf("checkbox") == -1 ){
				// not a checkbox
				continue;
  				}else if(e.checked == true && originalMoveDay == MoveDay){
				originalMoveDay = e.name;
				somethingChecked = true;
				break;
				}else if(e.checked == true){
				somethingChecked = true;
				}
}//END figure out which day is checked.




	if(dropDown == MoveTime && MoveDay == originalMoveDay){//set to original day and time..no good
		alert("Please select a different destination for " + MoveSpot + " than its original slot!");
	}else if(somethingChecked == false){//no days are checked
		alert("Please select a day for " + MoveSpot + "!");
	}else if(alreadyScheduled != true){//add new move
	
		//hideCurrentPopup();

	
		changeObjectVisibility('glideDiv', 'visible');//Show Moves box on left rail...
		
				if(document.MyPopUp.mon.checked == true){
					var mon = true;
					diplayDays = diplayDays + "mon ";
				}else{
					var mon = false;
				}
				if(document.MyPopUp.tue.checked == true){
					var tue = true;
					diplayDays = diplayDays + "tue ";
				}else{
					var tue = false;
				}
				if(document.MyPopUp.wed.checked == true){
					var wed = true;
					diplayDays = diplayDays + "wed ";
				}else{
					var wed = false;
				}
				if(document.MyPopUp.thu.checked == true){
					var thu = true;
					diplayDays = diplayDays + "thu ";
				}else{
					var thu = false;
				}
				if(document.MyPopUp.fri.checked == true){
					var fri = true;
					diplayDays = diplayDays + "fri ";
				}else{
					var fri = false;
				}
				if(document.MyPopUp.sat.checked == true){
					var sat = true;
					diplayDays = diplayDays + "sat ";
				}else{
					var sat = false;
				}
				if(document.MyPopUp.sun.checked == true){
					var sun = true;
					diplayDays = diplayDays + "sun ";
				}else{
					var sun = false;
				}
				
				var pointer = movesArray.length;
				movesArray[pointer] = new newMove(MoveID,MoveSpot,dropDown,diplayDays,mon,tue,wed,thu,fri,sat,sun);
				
				//Populate Move Cell
				for (var q=0; q < movesArray.length; q++) {
							var hour = movesArray[q].time.substring(0,2);
							var rest = movesArray[q].time.substring(2,8);
							Myhour = parseInt(hour);
							if(Myhour > 12){
								var newHour = 12-(24 - Myhour);
								var diplayTime = newHour +  rest + "pm";
							}else{
								var diplayTime = movesArray[q].time + "am";
							}
		
					diplayMoves = diplayMoves + "&#8226;" + movesArray[q].spot + "<A href=\"javascript:dropMove('" + movesArray[q].spot + "','" + q + "');\"><IMG src=\"images/dropMove.gif\" border=\"0\" align=\"right\"></A><BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + movesArray[q].MydisplayDays + "<BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + diplayTime + "<HR>";
				}
				document.getElementById("Moves").innerHTML = diplayMoves;
				
				//disable "Move to" button to prevent duplicates
				DisableButtons();

	}//end else statment
}//end add move to box on left rail


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// COPY SPOT FUNCTION
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//removes item from sidebar
function dropCopy(spot,ID){
	//alert(movesArray.length);
	//MyID = parseInt(ID);
	copyArray.splice(ID,1);
	//alert(movesArray.length);
	//Populate Move Cell
		var displayCopies = "";
		for (var q=0; q < copyArray.length; q++) {
							var hour = copyArray[q].time.substring(0,2);
							var rest = copyArray[q].time.substring(2,8);
							Myhour = parseInt(hour);
							if(Myhour > 12){
								var newHour = 12-(24 - Myhour);
								var displayTime = newHour +  rest + "pm";
							}else{
								var displayTime = copyArray[q].time + "am";
							}

		
					displayCopies = displayCopies + "&#8226;" + copyArray[q].spot + "<A href=\"javascript:dropCopy('" + copyArray[q].spot + "','" + q + "');\"><IMG src=\"images/dropMove.gif\" border=\"0\" align=\"right\"></A><BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + copyArray[q].MydisplayDays + "<BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + displayTime + "<HR>";
				}
				document.getElementById("Copies").innerHTML = displayCopies;
}//end dropMove



copyArray = new Array();//array that holds scheduled Copies from switchboard

function newCopy(ID,spot,time,MydisplayDays,mon,tue,wed,thu,fri,sat,sun){
	this.ID = ID;
	this.spot = spot;
	this.time = time;
	this.MydisplayDays = MydisplayDays;
	this.mon = mon;
	this.tue = tue;
	this.wed = wed;
	this.thu = thu;
	this.fri = fri;
	this.sat = sat;
	this.sun = sun;
}//end newMove

function addCopy(){
	searchArrayDuplicates('copy');
		//hideCurrentPopup();

				var diplayDays = "";
				var displayCopies = "";
				var dropDown = eval("document.MyPopUp.time.value");
	
	//determine if time and day have been changed so as not to move a spot back to itself
	//figure out which day is checked...
	somethingChecked = false;
	for (var q=0; q < document.MyPopUp.elements.length; q++) {

				 // get each element of form form
				 var e = document.MyPopUp.elements[q];
				 originalMoveDay = e.name;
				 if(e.type.indexOf("checkbox") == -1 ){
				// not a checkbox
				continue;
  				}else if(e.checked == true && originalMoveDay == MoveDay){
				originalMoveDay = e.name;
				somethingChecked = true;
				break;
				}else if(e.checked == true){
				somethingChecked = true;
				}
}//END figure out which day is checked.




	if(dropDown == MoveTime && MoveDay == originalMoveDay){//set to original day and time..no good
		alert("Please select a different destination for " + MoveSpot + " than its original slot!");
	}else if(somethingChecked == false){//no days are checked
		alert("Please select a day for " + MoveSpot + "!");
	}else if(alreadyScheduled != true){//add new move
	
		changeObjectVisibility('glideDiv', 'visible');//Show Moves box on left rail...
		
				if(document.MyPopUp.mon.checked == true){
					var mon = true;
					diplayDays = diplayDays + "mon ";
				}else{
					var mon = false;
				}
				if(document.MyPopUp.tue.checked == true){
					var tue = true;
					diplayDays = diplayDays + "tue ";
				}else{
					var tue = false;
				}
				if(document.MyPopUp.wed.checked == true){
					var wed = true;
					diplayDays = diplayDays + "wed ";
				}else{
					var wed = false;
				}
				if(document.MyPopUp.thu.checked == true){
					var thu = true;
					diplayDays = diplayDays + "thu ";
				}else{
					var thu = false;
				}
				if(document.MyPopUp.fri.checked == true){
					var fri = true;
					diplayDays = diplayDays + "fri ";
				}else{
					var fri = false;
				}
				if(document.MyPopUp.sat.checked == true){
					var sat = true;
					diplayDays = diplayDays + "sat ";
				}else{
					var sat = false;
				}
				if(document.MyPopUp.sun.checked == true){
					var sun = true;
					diplayDays = diplayDays + "sun ";
				}else{
					var sun = false;
				}
				var pointer = copyArray.length;
				copyArray[pointer] = new newCopy(MoveID,MoveSpot,dropDown,diplayDays,mon,tue,wed,thu,fri,sat,sun);
				//Populate Move Cell
				for (var q=0; q < copyArray.length; q++) {
							var hour = copyArray[q].time.substring(0,2);
							var rest = copyArray[q].time.substring(2,8);
							Myhour = parseInt(hour);
							if(Myhour > 12){
								var newHour = 12-(24 - Myhour);
								var displayTime = newHour +  rest + "pm";
							}else{
								var displayTime = copyArray[q].time + "am";
							}

		
					displayCopies = displayCopies + "&#8226;" + copyArray[q].spot + "<A href=\"javascript:dropCopy('" + copyArray[q].spot + "','" + q + "');\"><IMG src=\"images/dropMove.gif\" border=\"0\" align=\"right\"></A><BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + copyArray[q].MydisplayDays + "<BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + displayTime + "<HR>";
				}
				document.getElementById("Copies").innerHTML = displayCopies;
				
				//disable "Move to" button to prevent duplicates
				DisableButtons();
	}//end else statment
}//end add move to box on left rail



//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// UPDATE SPOT FUNCTION
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
updateArray = new Array();//array that holds scheduled Copies from switchboard


//removes item from sidebar
function dropUpdate(spot,ID){
	//alert(movesArray.length);
	//MyID = parseInt(ID);
	updateArray.splice(ID,1);
	//alert(movesArray.length);
	//Populate Move Cell
		var displayCopies = "";
		for (var q=0; q < updateArray.length; q++) {
							var hour = updateArray[q].time.substring(0,2);
							var rest = updateArray[q].time.substring(2,8);
							Myhour = parseInt(hour);
							if(Myhour > 12){
								var newHour = 12-(24 - Myhour);
								var displayTime = newHour +  rest + "pm";
							}else{
								var displayTime = updateArray[q].time + "am";
							}

		
					displayCopies = displayCopies + "&#8226;" + updateArray[q].spot + "<A href=\"javascript:dropUpdate('" + updateArray[q].spot + "','" + q + "');\"><IMG src=\"images/dropMove.gif\" border=\"0\" align=\"right\"></A><BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + updateArray[q].MydisplayDays + "<BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + displayTime + "<HR>";
				}
				document.getElementById("UpdatesYo").innerHTML = displayCopies;
}//end dropMove



function newUpdate(ID,spot,time,MydisplayDays,mon,tue,wed,thu,fri,sat,sun){
	this.ID = ID;
	this.spot = spot;
	this.time = time;
	this.MydisplayDays = MydisplayDays;
	this.mon = mon;
	this.tue = tue;
	this.wed = wed;
	this.thu = thu;
	this.fri = fri;
	this.sat = sat;
	this.sun = sun;
}//end newMove

function addUpdate(){
searchArrayDuplicates('update');

if(alreadyScheduled != true){
	//hideCurrentPopup();
}


				var diplayDays = "";
				var displayUpdates = "";
				var dropDown = eval("document.MyPopUp.time.value");
	
	//determine if time and day have been changed so as not to move a spot back to itself
	//figure out which day is checked...
	somethingChecked = false;
	for (var q=0; q < document.MyPopUp.elements.length; q++) {

				 // get each element of form form
				 var e = document.MyPopUp.elements[q];
				 originalMoveDay = e.name;
				 if(e.type.indexOf("checkbox") == -1 ){
				// not a checkbox
				continue;
  				}else if(e.checked == true && originalMoveDay == MoveDay){
				originalMoveDay = e.name;
				somethingChecked = true;
				break;
				}else if(e.checked == true){
				somethingChecked = true;
				}
}//END figure out which day is checked.




	if(somethingChecked == false){//no days are checked
		alert("Please select a day for " + MoveSpot + "!");
	}else if(alreadyScheduled != true){//add new move
	
		changeObjectVisibility('glideDiv', 'visible');//Show Moves box on left rail...
		
				if(document.MyPopUp.mon.checked == true){
					var mon = true;
					diplayDays = diplayDays + "mon ";
				}else{
					var mon = false;
				}
				if(document.MyPopUp.tue.checked == true){
					var tue = true;
					diplayDays = diplayDays + "tue ";
				}else{
					var tue = false;
				}
				if(document.MyPopUp.wed.checked == true){
					var wed = true;
					diplayDays = diplayDays + "wed ";
				}else{
					var wed = false;
				}
				if(document.MyPopUp.thu.checked == true){
					var thu = true;
					diplayDays = diplayDays + "thu ";
				}else{
					var thu = false;
				}
				if(document.MyPopUp.fri.checked == true){
					var fri = true;
					diplayDays = diplayDays + "fri ";
				}else{
					var fri = false;
				}
				if(document.MyPopUp.sat.checked == true){
					var sat = true;
					diplayDays = diplayDays + "sat ";
				}else{
					var sat = false;
				}
				if(document.MyPopUp.sun.checked == true){
					var sun = true;
					diplayDays = diplayDays + "sun ";
				}else{
					var sun = false;
				}
				var pointer = updateArray.length;
				updateArray[pointer] = new newUpdate(MoveID,MoveSpot,dropDown,diplayDays,mon,tue,wed,thu,fri,sat,sun);
				//Populate Move Cell
				for (var q=0; q < updateArray.length; q++) {
							var hour = updateArray[q].time.substring(0,2);
							var rest = updateArray[q].time.substring(2,8);
							Myhour = parseInt(hour);
							if(Myhour > 12){
								var newHour = 12-(24 - Myhour);
								var displayTime = newHour +  rest + "pm";
							}else{
								var displayTime = updateArray[q].time + "am";
							}

		
					displayUpdates = displayUpdates + "&#8226;" + updateArray[q].spot + "<A href=\"javascript:dropUpdate('" + updateArray[q].spot + "','" + q + "');\"><IMG src=\"images/dropMove.gif\" border=\"0\" align=\"right\"></A><BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + updateArray[q].MydisplayDays + "<BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + displayTime + "<HR>";
				}
				document.getElementById("UpdatesYo").innerHTML = displayUpdates;
				//disable "Move to" button to prevent duplicates
				DisableButtons();
	}//end else statment
}//end add move to box o


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// DELETE SPOT FUNCTION
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

deleteArray = new Array();//array that holds scheduled Copies from switchboard


//removes item from sidebar
function dropDelete(spot,ID){
	//alert(movesArray.length);
	//MyID = parseInt(ID);
	deleteArray.splice(ID,1);
	//alert(movesArray.length);
	//Populate Move Cell
		var displayCopies = "";
		for (var q=0; q < deleteArray.length; q++) {
							var hour = deleteArray[q].time.substring(0,2);
							var rest = deleteArray[q].time.substring(2,8);
							Myhour = parseInt(hour);
							if(Myhour > 12){
								var newHour = 12-(24 - Myhour);
								var displayTime = newHour +  rest + "pm";
							}else{
								var displayTime = deleteArray[q].time + "am";
							}

		
					displayCopies = displayCopies + "&#8226;" + deleteArray[q].spot + "<A href=\"javascript:dropDelete('" + deleteArray[q].spot + "','" + q + "');\"><IMG src=\"images/dropMove.gif\" border=\"0\" align=\"right\"></A><BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + deleteArray[q].MydisplayDays + "<BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + displayTime + "<HR>";
				}
				document.getElementById("Deletes").innerHTML = displayCopies;
}//end dropMove



function newDelete(ID,spot,time,MydisplayDays,mon,tue,wed,thu,fri,sat,sun){
	this.ID = ID;
	this.spot = spot;
	this.time = time;
	this.MydisplayDays = MydisplayDays;
	this.mon = mon;
	this.tue = tue;
	this.wed = wed;
	this.thu = thu;
	this.fri = fri;
	this.sat = sat;
	this.sun = sun;
}//end newMove

function addDelete(){
	
searchArrayDuplicates('delete');

if(alreadyScheduled != true){
	//hideCurrentPopup();
}


				var diplayDays = "";
				var displayDelete = "";
				var dropDown = eval("document.MyPopUp.time.value");
	
	//determine if time and day have been changed so as not to move a spot back to itself
	//figure out which day is checked...
	somethingChecked = false;
	for (var q=0; q < document.MyPopUp.elements.length; q++) { 

				 // get each element of form form
				 var e = document.MyPopUp.elements[q];
				 originalMoveDay = e.name;
				 if(e.type.indexOf("checkbox") == -1 ){
				// not a checkbox
				continue;
  				}else if(e.checked == true && originalMoveDay == MoveDay){
				originalMoveDay = e.name;
				somethingChecked = true;
				break;
				}else if(e.checked == true){
				somethingChecked = true;
				}
}//END figure out which day is checked.




	if(somethingChecked == false){//no days are checked
		alert("Please select a day for " + MoveSpot + "!");
	}else if(alreadyScheduled != true){//add new move
	
		changeObjectVisibility('glideDiv', 'visible');//Show Moves box on left rail...
		
				if(document.MyPopUp.mon.checked == true){
					var mon = true;
					diplayDays = diplayDays + "mon ";
				}else{
					var mon = false;
				}
				if(document.MyPopUp.tue.checked == true){
					var tue = true;
					diplayDays = diplayDays + "tue ";
				}else{
					var tue = false;
				}
				if(document.MyPopUp.wed.checked == true){
					var wed = true;
					diplayDays = diplayDays + "wed ";
				}else{
					var wed = false;
				}
				if(document.MyPopUp.thu.checked == true){
					var thu = true;
					diplayDays = diplayDays + "thu ";
				}else{
					var thu = false;
				}
				if(document.MyPopUp.fri.checked == true){
					var fri = true;
					diplayDays = diplayDays + "fri ";
				}else{
					var fri = false;
				}
				if(document.MyPopUp.sat.checked == true){
					var sat = true;
					diplayDays = diplayDays + "sat ";
				}else{
					var sat = false;
				}
				if(document.MyPopUp.sun.checked == true){
					var sun = true;
					diplayDays = diplayDays + "sun ";
				}else{
					var sun = false;
				}
				var pointer = deleteArray.length;
				deleteArray[pointer] = new newDelete(MoveID,MoveSpot,dropDown,diplayDays,mon,tue,wed,thu,fri,sat,sun);
				//Populate Move Cell
				for (var q=0; q < deleteArray.length; q++) {
							var hour = deleteArray[q].time.substring(0,2);
							var rest = deleteArray[q].time.substring(2,8);
							Myhour = parseInt(hour);
							if(Myhour > 12){
								var newHour = 12-(24 - Myhour);
								var displayTime = newHour +  rest + "pm";
							}else{
								var displayTime = deleteArray[q].time + "am";
							}

		
					displayDelete = displayDelete + "&#8226;" + deleteArray[q].spot + "<A href=\"javascript:dropDelete('" + deleteArray[q].spot + "','" + q + "');\"><IMG src=\"images/dropMove.gif\" border=\"0\" align=\"right\"></A><BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + deleteArray[q].MydisplayDays + "<BR><span class=\"swtichBoardBulletColor\">&#8226;</span>" + displayTime + "<HR>";
				}
				document.getElementById("Deletes").innerHTML = displayDelete;
				//disable "Move to" button to prevent duplicates
				DisableButtons();
	}//end else statment
}//end add move to box o

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// OTHER FUNCTIONS
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function DisableButtons(){
	document.MyPopUp.switchyo.disabled = true;
	document.MyPopUp.copyyo.disabled = true;
	document.MyPopUp.update.disabled = true;
	document.MyPopUp.deleteyo.disabled = true;
}

function EnableButtons(){
	document.MyPopUp.switchyo.disabled = false;
	document.MyPopUp.copyyo.disabled = false;
	document.MyPopUp.update.disabled = false;
	document.MyPopUp.deleteyo.disabled = false;
}


var xOffset = -165;
var yOffset = -250;
newX = "";
newY = "";
function showPopup (targetObjectId,eventObj,UW,spots,rates,dates,types,length,mytime,day,ID) {

    EnableButtons();

	//Stuff to populate Switch Board Table
	MoveID = ID;
	MoveSpot = spots;
	MoveTime = mytime;
	MoveDay = day;
	
	

if (self.innerWidth)//netscape flavors
{
	frameWidth = self.innerWidth;
	frameHeight = self.innerHeight;
	scrollAmount = window.pageYOffset;
}
else if (document.documentElement && document.documentElement.clientWidth)//IE 6
{
	frameWidth = document.documentElement.clientWidth;
	frameHeight = document.documentElement.clientHeight;
	scrollAmount = document.body.scrollTop;
}
else if (document.body)//All other flavors of IE
{
	frameWidth = document.body.clientWidth;
	frameHeight = document.body.clientHeight;
	scrollAmount = document.body.scrollTop;
}
//alert (scrollAmount);
if(newX == ""){
  newX = (frameWidth/2) - ((document.getElementById('spotInfo').offsetWidth)/2);
}

//NewdistanceFromTop = document.getElementById('spotInfo').offsetTop;
//alert(NewdistanceFromTop);
if(newY == ""){
  newY = ((frameHeight/2) - (document.getElementById('spotInfo').offsetHeight/2)) + scrollAmount;
}else if(previousScroll == scrollAmount){
  newY = document.getElementById('spotInfo').offsetTop;
}else if(scrollAmount > previousScroll && ((scrollAmount - previousScroll) < distanceFromTop)){//scrolling down the oage
newY = originaldistanceFromTop;
}else if(previousScroll > scrollAmount  && (((previousScroll - scrollAmount) + distanceFromTop) < (frameHeight - document.getElementById('spotInfo').offsetHeight))){//scrollling upwards
newY = originaldistanceFromTop;
}else{
  newY = distanceFromTop + scrollAmount;
}

	document.getElementById("uw").innerHTML = UW;
	document.getElementById("spot").innerHTML = spots;
	document.getElementById("rate").innerHTML = rates;
	document.getElementById("date").innerHTML = dates;
	document.getElementById("type").innerHTML = types;
	document.getElementById("SpotLength").innerHTML = length + " seconds";
	document.MyPopUp.time.value=mytime;
	document.MyPopUp.mon.checked=false;
	document.MyPopUp.tue.checked=false;
	document.MyPopUp.wed.checked=false;
	document.MyPopUp.thu.checked=false;
	document.MyPopUp.fri.checked=false;
	document.MyPopUp.sat.checked=false;
	document.MyPopUp.sun.checked=false;
	//document.MyPopUp.eval(day).checked=true;
	if(day == 'mon'){
		document.MyPopUp.mon.checked=true;
	}else if (day == 'tue'){
		document.MyPopUp.tue.checked=true;
	}else if (day == 'wed'){
		document.MyPopUp.wed.checked=true;
	}else if (day == 'thu'){
		document.MyPopUp.thu.checked=true;
	}else if (day == 'fri'){
		document.MyPopUp.fri.checked=true;
	}else if (day == 'sat'){
		document.MyPopUp.sat.checked=true;
	}else if (day == 'sun'){
		document.MyPopUp.sun.checked=true;
	}
	setDay = day;
	
    if(eventObj) {
	// hide any currently-visible popups
	hideCurrentPopup();
	// stop event from bubbling up any farther
	eventObj.cancelBubble = true;
	// move popup div to current cursor position 
	// (add scrollTop to account for scrolling for IE)

    //var newXCoordinate = (eventObj.pageX)?eventObj.pageX + xOffset:eventObj.x + ((document.body.scrollLeft)?document.body.scrollLeft:0);
	//var newYCoordinate = (eventObj.pageY)?eventObj.pageY + yOffset:eventObj.y + yOffset + ((document.body.scrollTop)?document.body.scrollTop:0);
	
	moveObject(targetObjectId, newX, newY);
	// and make it visible
	if( changeObjectVisibility(targetObjectId, 'visible') ) {
	    // if we successfully showed the popup
	    // store its Id on a globally-accessible object
	    window.currentlyVisiblePopup = targetObjectId;
		 nullDays();//Disable Check boxes according to Time selected
	    return true;
	} else {
	    // we couldn't show the popup, boo hoo!
	    return false;
	}
    } else {
	// there was no event object, so we won't be able to position anything, so give up
	return false;
    }

} // showPopup

function hideCurrentPopup() {
    // note: we've stored the currently-visible popup on the global object window.currentlyVisiblePopup
    if(window.currentlyVisiblePopup) {
	changeObjectVisibility(window.currentlyVisiblePopup, 'hidden');
	window.currentlyVisiblePopup = false;
	newX = document.getElementById('spotInfo').offsetLeft;
	//newY =	distanceFromTop + scrollAmount;
	
	//newY = document.getElementById('spotInfo').offsetTop + scrollAmount;
	//alert(document.getElementById('spotInfo').offsetHeight);
    }

	
} // hideCurrentPopup



// ***********************
// hacks and workarounds *
// ***********************

// initialize hacks whenever the page loads
//window.onload = initializeHacks;

// setup an event handler to hide popups for generic clicks on the document
document.onclick = hideCurrentPopup;

function initializeHacks() {
    // this ugly little hack resizes a blank div to make sure you can click
    // anywhere in the window for Mac MSIE 5
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	window.onresize = explorerMacResizeFix;
    }
    resizeBlankDiv();
    // this next function creates a placeholder object for older browsers
    createFakeEventObj();
}

function createFakeEventObj() {
    // create a fake event object for older browsers to avoid errors in function call
    // when we need to pass the event object to functions
    if (!window.event) {
	window.event = false;
    }
} // createFakeEventObj

function resizeBlankDiv() {
    // resize blank placeholder div so IE 5 on mac will get all clicks in window
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	getStyleObject('blankDiv').width = document.body.clientWidth - 20;
	getStyleObject('blankDiv').height = document.body.clientHeight - 20;
    }
}

function explorerMacResizeFix() {
    location.reload(false);
}

